/**
 * 无穷计数器
 */
function * fn() {
    for(let i = 0;;i++) {
        yield i;
    }
}

var counter = fn();


console.log(counter.next());
console.log(counter.next());
console.log(counter.next());

// { value: 0, done: false }
// { value: 1, done: false }
// { value: 2, done: false }